﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using NUnit.Framework;
using EnumUtils;
using EnumUtils.Extensions;

namespace EnumUtilsTests.Extensions
{
  [TestFixture]
  public class BitArrayExtensionsTests
  {
    [Test]
    [ExpectedException(typeof(ArgumentNullException))]
    public void
    AsEnumerableNullBitArrayTest( ) {
      BitArray nullBitArray = default(BitArray);
      IEnumerable<bool> nullBitArrayIter = nullBitArray.AsEnumerable();

      Assert.Fail("{0} was not thrown when it should have been.", typeof(ArgumentNullException));
    }


    [Test]
    public void
    AsEnumerableOperationalCorrectnessTest( ) {
      BitArray testBitArray = new BitArray(new int[] { 0x70F0F0F0, 0x0F0F0F0F });
      //IEnumerator<bool> testBitArrayGenericEnum = testBitArray.GetGenericEnumerator();
      IEnumerator testBitArrayEnum = testBitArray.GetEnumerator();
      IEnumerator<bool> testBitArrayEnumFromIEnumerable = testBitArray.AsEnumerable().GetEnumerator();

      while (testBitArrayEnum.MoveNext() && testBitArrayEnumFromIEnumerable.MoveNext()) {
        Assert.AreEqual(testBitArrayEnum.Current, testBitArrayEnumFromIEnumerable.Current);
      }

    }
  }
}
